package pure.engine.world.decorator 
{
	import flash.display.DisplayObjectContainer;
	import pure.engine.world.IMonitor;
	import pure.engine.world.Monitor;
	import pure.engine.core.ns_despair;
	
	use namespace ns_despair;
	
	/**
	 * 监视器装饰者
	 * [Author] - PURE
	 * 
	 */
public class MonitorDecorator extends Monitor 
{
	public function MonitorDecorator(baseMonitor:IMonitor)
	{
		var owner:DisplayObjectContainer;
		
		this.m_baseMonitor  =  baseMonitor as Monitor;
		this.m_viewW        =  m_baseMonitor.m_viewW;
		this.m_viewH        =  m_baseMonitor.m_viewH;
		this.m_name         =  m_baseMonitor.m_name;
		
		if (m_baseMonitor.parent)
		{
			owner   =  m_baseMonitor.parent;
			this.x  =  m_baseMonitor.x;
			this.y  =  m_baseMonitor.y;
			
			this.addChild(m_baseMonitor);
			owner.addChild(this);
		}
		else
		{
			this.addChild(m_baseMonitor);
		}
		m_baseMonitor.x = m_baseMonitor.y = 0;
	}
	
	
	
	
	/**
	 * 更新
	 */
	override public function update(deltaTime:Number):void
	{
		m_baseMonitor.update(deltaTime);
	}
	
	
	/**
	 * 退出
	 */
	override ns_despair function enterWorld():void
	{
		m_baseMonitor.enterWorld();
	}
	
	
	/**
	 * 退出
	 */
	override ns_despair function exitWorld():void
	{
		m_baseMonitor.exitWorld();
	}

	
	/**
	 * 完成退出
	 */
	override ns_despair function finishExit():void
	{
		m_baseMonitor.finishExit();
	}
	
	
	
	
	//======================
	// Member
	//======================
	
	
	ns_despair var m_baseMonitor:Monitor;
}

}